package net.scalan;

import javax.persistence.EntityManager;
import net.scalan.jpa.PersistenceService;
import net.scalan.jpa.model.DBELink;
import net.scalan.jpa.model.DBELinkCanRange;
import net.scalan.jpa.model.DBStation;

/**
 *
 * @author scalan
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int generateSchemObjects = 5000;

        DBStation station = new DBStation();
        station.setName("Test station...");

        for(int i=0; i<4; i++){
            DBELink elink = new DBELink();
            elink.setName("Test E-Link (" + i +")...");
            elink.setHost("localhost");
            elink.setPort(10004);
            elink.setStation(station);
            for(int j=0; j<8; j++){
                DBELinkCanRange range = new DBELinkCanRange();
                range.setCan_id_min(j*100L);
                range.setElink(elink);
                elink.getElinkCanRanges().add(range);
            }
            station.getElinks().add(elink);
        }
        EntityManager em = PersistenceService.getEntityManager();
        em.getTransaction().begin();
        em.persist(station);
        em.getTransaction().commit();
        em.close();
        
        /*
        // TODO code application logic here
        DBTest record = new DBTest();
        record.setName("test...");
        DBTestController dbTestController = new DBTestController();
        dbTestController.create(record);

        // SchemObjects
        DBSchemObjectController dbSchemObjectController = new DBSchemObjectController();
        for (int i = 0; i < generateSchemObjects; i++) {
            int x = (int) (Math.random() * 1000);
            int y = (int) (Math.random() * 750);
            DBSchemObject schemObject = new DBSchemObject();
            schemObject.setName("SchemObject_" + i);
            schemObject.setX((int) (Math.random() * 1000));
            schemObject.setY((int) (Math.random() * 750));
            dbSchemObjectController.create(schemObject);
        }
         *
         */
    }
}
